# coding: utf8

import requests
import time
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

def postFunction(start,end,url,params):
    
    starttime = time.time()
    s = starttime
    
    for x in range(start,end):
        data = params
        print('send data: %s' % str(data))
        try:
            res = requests.post(url,data=data)
            print("---headers---",res.headers)
            print("---cookies---",res.cookies)
            print("---cookieslen---",len(res.cookies))
            r = open("log.html","w")
            r.write(res.text)
            r.close()
            print("---printlog.html---","ok")
        except Exception as e:
            print("-----error-----",e)
        e = time.time()
        print("take time: %s" % (e - s))
        s = e
         
    endtime = time.time()
    print("take time: %s" % (endtime - starttime))
    
    
def getFunction(start,end,url,params):

    starttime = time.time()
    s = starttime
    
    for x in range(start,end):
        data = params
        print('send data: %s' % str(data))
        try:
            res = requests.get(url,params=data)
            print("---headers---",res.headers)
            print("---cookies---",res.cookies)
            print("---cookieslen---",len(res.cookies))
            r = open("log.html","w")
            r.write(res.text)
            r.close()
            print("---printlog.html---","ok")
        except Exception as e:
            print("-----error-----",e)
        e = time.time()
        print("take time: %s" % (e - s))
        s = e
        
    endtime = time.time()
    print("take time: %s" % (endtime - starttime))